<template>
	<view class="index-list animated fadeInLeft fast">
		<view class="index-list1 u-f-ac">
			<view class="u-f-ajc">
				<image :src="item.userpic"></image>{{item.username}}
			</view>
			<view class="u-f-ajc" v-if="!isguanzhu" @click="guanzhu()">
				<view class="icon iconfont icon-tag27fuben"></view>
				关注
			</view>
			<view class="u-f-ajc" v-else>
				已关注
			</view>
		</view>
		<view class="index-list2" @click="opendetail">
			{{item.title}}
		</view>

		<view class="index-list3 .u-f-ajc" @click="opendetail">
			<!--图片-->
			<image :src="item.titlepic"></image>
			<!--视频-->
			<template v-if="item.type=='video'">
				<view class="icon iconfont icon-bofang index-list3-play ">

				</view>
				<view class="index-list3-playInfo">
					{{item.playnum}}次播放 {{item.long}}
				</view>
			</template>
		</view>
		<view class="index-list4 u-f-ac">
			<view class="u-f-ajc">
				<view class="u-f-ajc" :class="{'active':(infonum.index==1)}" @click="caozuo('ding')">
					<view class="icon iconfont icon-xiaolian"></view>
					{{infonum.dingnum}}
				</view>
				<view class="u-f-ajc" :class="{'active':(infonum.index==2)}" @click="caozuo('cai')">
					<view class="icon iconfont icon-bad"></view>
					{{infonum.cainum}}
				</view>
			</view>
			<view class="u-f-ajc">
				<view class="u-f-ajc">
					<view class="icon iconfont icon-svg-"></view>
					{{item.commentnum}}
				</view>
				<view class="u-f-ajc">
					<view class="icon iconfont icon-wanjiantou-"></view>
					{{item.sharenum}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item: Object,
			index: Number
		},
		data() {
			return {
				isguanzhu: this.item.isguanzhu,
				infonum: this.item.infonum
			}
		},
		methods: {
			//关注
			guanzhu() {
				this.isguanzhu = true;
				uni.showToast({
					title: '关注成功'
				})
			},
			//顶踩
			caozuo(type) {
				switch (type) {
					case 'ding':
						if (this.infonum.index == 1) {
							return;
						}
						this.infonum.dingnum++;
						if (this.infonum.index == 2) {
							this.infonum.cainum--;
						}
						this.infonum.index = 1;
						break;
					case 'cai':
						if (this.infonum.index == 2) {
							return;
						}
						this.infonum.cainum++;
						if (this.infonum.index == 1) {
							this.infonum.dingnum--;
						}
						this.infonum.index = 2;
						break;
				}

			},
			//进入详情页
			opendetail() {

			}
		}
	}
</script>

<style lang="scss" scoped>
	.index-list {
		padding: 20rpx;
		border-bottom: 1rpx solid #EEEEEE;

		.index-list1 {
			view:nth-child(1) {
				color: #999999;

				image {
					width: 90rpx;
					height: 90rpx;
					border-radius: 100%;
					margin-right: 10rpx;
				}
			}

			view:nth-child(2) {
				background-color: #F4F4F4;
				border-radius: 5rpx;
				padding: 0 20rpx;
			}
		}

		.index-list2 {
			padding-top: 15rpx;
			font-size: 30rpx;
		}

		.index-list3 {
			position: relative; //相对定位
			padding-top: 15rpx;

			image {
				width: 100%;
				border-radius: 20rpx;
			}

			.index-list3-play {
				position: absolute;
				font-size: 140rpx;
				right: 300rpx;
				bottom: 120rpx;
				color: #FFFFFF;
			}

			.index-list3-playInfo {
				position: absolute;
				background-color: #333333;
				color: #FFFFFF;
				bottom: 18rpx;
				right: 8rpx;
				border-radius: 40rpx;
				font-size: 18rpx;
				padding: 0 18rpx;
			}
		}

		.index-list4 {
			padding: 15rpx;

			view {
				color: #999999;

				view {
					margin-right: 15rpx;

					view {
						margin-right: 10rpx;
					}
				}

				.active {
					view {
						color: #09BB07;
					}
				}
			}
		}
	}
</style>
